#ifndef _AGENTIMPL_H_
#define _AGENTIMPL_H_

#include "stdafx.h"
#include "auth.hpp"

class CAgentImpl :	public  IAgent,
					public  IOperationEvent,
					public	CChannel,
					public	CUnknownImp
		
{
public:
	CAgentImpl(void);
	virtual ~CAgentImpl(void);

	BEGIN_STDCOM_MAP
		STDCOM_INTERFACE_ENTRY_UNKNOWN_(IAgent)
		STDCOM_INTERFACE_ENTRY(IOperationEvent)
		STDCOM_INTERFACE_ENTRY(IAgent)
	END_STDCOM_MAP

public:
	//IAgent
	std_method(SetId)(unsigned int id);
	std_method(Bind)(LPCSTR addr, int len);
	std_method(Close)();
	std_method(Recv)(IBase* pBase);
	std_method(Send)(IBase* pBase);

	//IOperationEvent
	std_method(OnComplete)(IBase *pOperation, event_id event, ULONG error_code);
private:
	std_method(OnConnected)(IBase *pIBase);
	std_method(OnSendSeqed)(IBase *pIBase);
	std_method(OnRecvSeqAcked)(IBase *pIBase);
	std_method(OnSendAcked)(IBase *pIBase);
	std_method(OnRecvHeaded)(IBase *pIBase);
	std_method(OnRecved)(IBase *pIBase);
	std_method(OnSendHeaded)(IBase *pIBase);
	std_method(OnSended)(IBase *pIBase);
private:
	CSemHandle		m_sem;
	unsigned int	m_id;
	BusProtocol		m_bus;
};

#endif
